#include<iostream>
#include<cstdlib>
#include<cstring>
#include<vector>

int adjust(std::vector<double> &_arr,int _n,int _m);
int sort(std::vector<double> &_arr);

int main (int argc, char *argv[]){
    int n;
    std::cin >> n;
    std::vector<double> arr(n);
    for(std::vector<double>::iterator arr_iterator = arr.begin();
      arr_iterator != arr.end();
      ++arr_iterator)
      std::cin >> *arr_iterator;
    sort(arr);
    std::cout << "A: ";
    for(std::vector<double>::iterator arr_iterator = arr.begin();
      arr_iterator != arr.end();
      ++arr_iterator)
      std::cout << *arr_iterator << " ";
    std::cout << std::endl;
    return 0;
}

/*a complete binary tree has been sorted
 *while i=1 , it is the root(the top)
 *while i>1 , it has a father-node #i/2
 *onlyif 2i<=n , it has a left-leaf #2i
 *onlyif 2i+1<=n , it has a right-leaf #2i+1
 */

int adjust(std::vector<double> &_arr,int _n,int _m)//make the tree's top(where i is smaller) is bigger
{
    double key=_arr[_n];
    for(int i = 2*_n; i<_m;i=i*2)//every left-leaf
    {
        //choose the bigger one
        if(_arr[i]<_arr[i+1])
        i++;
        //kid must be smaller than father
        if(key>_arr[i])
        break;
        _arr[_n]=_arr[i];
        _n=i;
    }
    _arr[_n]=key;
    return 0;
}

int sort(std::vector<double> &_arr){
    for(int i = _arr.size()/2; i>=0; i--)//everyone who has leaves
    {
        adjust(_arr,i,_arr.size());
    }
    //remove the biggest one(a[0]) and resort
    for(int i = _arr.size()-1;i>=0;i--){
        double temp = _arr[0];
        _arr[0]=_arr[i];
        _arr[i]=temp;
        adjust(_arr,0,i-1);
    }
    return 0;
}